Expose AddOrUpdateChild as a recipe using XPath + child XML #4533
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's changed?
Simple XML recipe that can add or update a child below the element(s) selected by XPath.
What's your motivation?
Provide more flexible ways of updating XML/pom files. In our specific case we need to configure
openapi-generator-maven-plugin
with<useJakartaEe>true</useJakartaEe>
when it matches<generatorName>spring</generatorName>
, followingJavaxMigrationToJakarta
(once this PR is merged, maybe it could be included there).Anything in particular you'd like reviewers to focus on?
I had considered offering the option to add the child even when it already exists, but that wouldn’t be idempotent. I implemented an option to not replace the child in such a case, disabled by default.
I based this branch on top of #4532 so the former should be merged first and it’s not needed to review the changes on XPath implementation. I just wanted to use the XPath fixes in the tests of this new recipe.
Have you considered any alternatives or workarounds?
I don’t think any other equivalent recipe exists.
ChangePluginConfiguration
only allows to override the whole configuration.Checklist